﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Text.RegularExpressions;

namespace BGCMS.Models
{
    /// <summary>
    /// A partial model class used for integrating validation and business rule logic
    /// </summary>
    public partial class HealthLog
    {
        /// <summary>
        /// Indicates whether the HealthLog object has any active RuleViolations
        /// </summary>
        public bool IsValid
        {
            get { return (HealthLogGetRuleViolations().Count() == 0); }
        }

        /// <summary>
        /// Causes our validation and business rules to be evaluated.
        /// </summary>
        /// <returns>Returns a sequence of HealthLogRuleViolation objects that 
        /// provide more details about any rule errors.</returns>
        public IEnumerable<HealthLogRuleViolation> HealthLogGetRuleViolations()
        {
                if (String.IsNullOrEmpty(Comment))
                yield return new HealthLogRuleViolation("Engin athugasemd", "Comment");

            yield break;
        }
    }

    /// <summary>
    /// A helper class that provides more details about a rule violation
    /// </summary>
    public class HealthLogRuleViolation
    {

        public string HealthLogErrorMessage { get; private set; }
        public string HealthLogPropertyName { get; private set; }

        public HealthLogRuleViolation(string errorMessage, string propertyName)
        {
            HealthLogErrorMessage = errorMessage;
            HealthLogPropertyName = propertyName;
        }
    }
}